import axios from '@/utils/request'

export default () => {
  return new Promise((resolve, reject) => {
    axios.post("/wxSharing/signature", {
      url: location.href
    }).then(res => {
      const {appId, timestamp, nonceStr, signature} = res
      wx.config({
        debug: true,
        appId, 
        timestamp,
        nonceStr,
        signature,
        jsApiList: ['scanQRCode'], // 必填，需要使用的JS接口列表
      })

      wx.ready(() => {
        resolve({appId})
      })

      wx.error((err) => {
        reject(err)
      })
    })

 
    
  })
}